package grammer.components;

/**
 * 
 * 
 * @author Minodor
 * 
 *         Enumeration for weather
 */

public enum WeatherEnum implements Component {
	DAWN, DUSK, GENERIC_WEATHER, RAIN, SNOW, SUNNY, WIND,TEMP_C;
	@Override
	public Component match(String toMatch) {
		for (WeatherEnum weather : WeatherEnum.values()) {
			if (weather.toString().equalsIgnoreCase(toMatch))
				return weather;
		}
		String s=toMatch.substring(0,toMatch.length()-1);
		try{
			Integer.parseInt(s);
			if (toMatch.endsWith("c") || toMatch.endsWith("C"))
				return TEMP_C;
		}catch(Exception e)
		{
			return null;
		}
		return null;
	}
	
	public static void main(String[] args)
	{
		System.out.println("ana".substring(0,2));
	}

	@Override
	public String toString() {
		switch (this) {
		case RAIN:
			return "Rain";
		case SUNNY:
			return "Sun";
		case DAWN:
			return "Dawn";
		case DUSK:
			return "Dusk";
		case WIND:
			return "Wind";
		case SNOW:
			return "Snow";
		case TEMP_C:
			return "Temperature Celsius";
		default:
			return "Weather";
		}
	}
}
